package main

import "strings"


func lengthOfLongestSubstring(s string) int {
    curr_str := ""
    max_len := 0

    for _, c := range(s) {
        ch := string(c)
        if !strings.Contains(curr_str, ch) {
            curr_str += ch
        } else {
            curr_str = curr_str[strings.Index(curr_str, ch)+1:] + ch
        }
        if len(curr_str) > max_len {
            max_len = len(curr_str)
        }
    }

    return max_len
}
